<template>
    <layout>
    	<mt-header title="添加监护人">
            <a href="/member/guardian" slot="left">

                <mt-button  icon="back"></mt-button>

            </a>

    	 <
		</mt-header>
			<div class="name fist_ch">
				<div class="left"> <i class="icon-shouji"></i> </div>
				<div class="right"><input type="text" v-model="fist" placeholder="对方手机号" /></div>
			</div>
			<div class="name">
				<div class="left"><i class="icon-shouji"></i> </div>
				<div class="right"><input type="text" v-model="fists" placeholder="确认手机号" /></div>
			</div>

        <mt-checklist
                title="用户关系"
                v-model="value"
                :options="relationshipList">
            </mt-checklist>
        <div class="selet">
            <div class="left"><i class="icon-11guanxi"></i></div>
            <div class="right">
                <select v-model='relationship' @change='' class='form-control'>
                    <template v-for="item in relationshipList">
                        <option :value='item.value'>{{ item.label }}</option>
                    </template>
                </select>
            </div>
        </div>

			<div class="footer" @click="edit">确认添加</div>
    </layout>
</template>
<style lang="scss">
    @import "index.scss";
</style>
<script type="text/babel">
    import { api } from 'framework/config.js';
    import Layout from "component/layout/standard";

    import Vue from 'vue'
    import Mint from 'mint-ui';
    Vue.use(Mint);

    export default {
        components: {
            Layout
        },
        data(){
            return {
                value: [1],
                relationshipList: [
                    {
                        value: 1,
                        label: '爸爸',
                    },
                    {
                        value: 2,
                        label: '妈妈',
                    },
                    {
                        value: 3,
                        label: '爷爷',
                    },
                    {
                        value: 4,
                        label: '奶奶',
                    },
                    {
                        value: 5,
                        label: '外公',
                    },
                    {
                        value: 6,
                        label: '外婆',
                    },
                    {
                        value: -1,
                        label: '其他',
                    }
                ],
				isfalse: false,
				fist:"18286087875",
				fists:"18286087875",
                relationship: 1
            }
        },
        computed: {
            api(){
                return api();
            }
        },
        methods: {
			// alter:function() {
            //
			// 	if(this.fist == this.fists){
			// 		console.log(this.fist)
			// 		console.log(this.fists)
			// 	}else{
			// 		console.log("bug")
			// 		alert("号码不一样")
             //        return false
			// 	}
			// },
            edit(){

                let param = new URLSearchParams();
                param.append("mobile", this.fists);
                param.append("relationship", this.relationship);

                Mint.Indicator.open();
                this.$http.post('/api/guardian/edit', param).then((response) => {
                    Mint.Indicator.close();
                    if (response.status == 200){
                        let data = response.data;
                        if (data.code == 200) {

                            Mint.Toast('设置成功');




                        }else{
                            Mint.Toast('设置失败');
                        }
                    }else{
                        Mint.Toast('设置失败');
                    }
                });
            }


        },
        created(){
        },
        mounted() {
        }
    }
</script>

